<template>
  <van-sticky>
    <div class="nav-bar">
      <div :style="{ width: leftWidth }" @click="handleBack">
        <slot name="left"></slot>
      </div>
      <div class="center">
        <slot name="center"></slot>
      </div>

      <div :style="{ width: rightWidth }">
        <slot name="right"></slot>
      </div>
    </div>
  </van-sticky>
</template>

<script>
export default {
  props: {
    leftWidth: {
      type: String,
      default: '60px'
    },
    rightWidth: {
      type: String,
      default: '60px'
    },
    isBack: {
      type: Boolean,
      default: false
    }
  },

  methods: {
    handleBack() {
      if (this.isBack) this.$router.back()
    }
  }
}
</script>

<style scoped lang="less">
.nav-bar {
  width: 100vw;
  display: flex;
  height: 44px;
  align-items: center;
  text-align: center;
  z-index: 999;
  .left,
  .right {
    width: 60px;
  }
  .center {
    flex: 1;
  }
}
</style>
